{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
    "def takePlayerInput():\n",
    "    player = \"blank\"\n",
    "    while not( player.lower() == \"r\" or player.lower() == \"p\" or player.lower() == \"s\") :\n",
    "        player = input(\"Please Enter your input out of - R | P | S = \")\n",
    "    return player.lower()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Please Enter your input out of - R | P | S = q\n",
      "Please Enter your input out of - R | P | S = v\n",
      "Please Enter your input out of - R | P | S = r\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'r'"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "takePlayerInput()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random \n",
    "\n",
    "def getBotInput():\n",
    "    lst = ['r','s','p']\n",
    "    return random.choice(lst)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'r'"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "getBotInput()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "def checkWinner(player,bot):\n",
    "    if player == 'r' and bot == \"r\":\n",
    "        return \"draw\"\n",
    "    elif player == \"r\" and bot == \"p\":\n",
    "        return \"bot\"\n",
    "    elif player == \"r\" and bot == \"s\":\n",
    "        return \"player\"\n",
    "    elif player == \"p\" and bot == \"s\":\n",
    "        return \"bot\"\n",
    "    elif player == \"p\" and bot == \"r\":\n",
    "        return \"player\"\n",
    "    elif player == \"p\" and bot == \"p\":\n",
    "        return \"draw\"\n",
    "    elif player == \"s\" and bot == \"r\":\n",
    "        return \"bot\"\n",
    "    elif player == \"s\" and bot == \"p\":\n",
    "        return \"player\"\n",
    "    elif player == \"s\" and bot == \"s\":\n",
    "        return \"draw\"\n",
    "    else:\n",
    "        return \"draw\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'bot'"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "checkWinner(player = \"r\",bot = \"p\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "def rockPaperScissor():\n",
    "    endTheGame = \"n\"\n",
    "    player_score = 0 \n",
    "    bot_score = 0\n",
    "    while endTheGame.lower() != \"y\":\n",
    "        ply = takePlayerInput()\n",
    "        bt = getBotInput()\n",
    "        print('Bot Entered - ', bt)\n",
    "        print(\" \")\n",
    "        winner = checkWinner(player = ply, bot = bt)\n",
    "        print(\" Winner is - \", winner)\n",
    "        print(\" \")\n",
    "        if winner == \"player\":\n",
    "            player_score += 2\n",
    "        elif winner == \"bot\":\n",
    "            bot_score += 2\n",
    "        else :\n",
    "            player_score += 1\n",
    "            bot_score += 1\n",
    "            \n",
    "        print(\"--Score board--\")\n",
    "        print(\"PLAYER \",player_score)\n",
    "        print(\"Bot ---\",bot_score)\n",
    "        print(\" \")\n",
    "        endTheGame = input(\"You want to end Y/N - \")\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Please Enter your input out of - R | P | S = r\n",
      "Bot Entered -  r\n",
      " \n",
      " Winner is -  draw\n",
      " \n",
      "----Score board ----\n",
      "---PLAYER ----- 1\n",
      "---Bot -------- 1\n",
      " \n",
      "You want to end Y/N - n\n",
      "Please Enter your input out of - R | P | S = r\n",
      "Bot Entered -  p\n",
      " \n",
      " Winner is -  bot\n",
      " \n",
      "----Score board ----\n",
      "---PLAYER ----- 1\n",
      "---Bot -------- 3\n",
      " \n",
      "You want to end Y/N - y\n"
     ]
    }
   ],
   "source": [
    "rockPaperScissor()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
